<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <table border="1">
    <caption>员工列表</caption>
    <tr>
      <th>编号</th><th>姓名</th><th>工资</th><th>工作</th><th>操作</th>
    </tr>
    <tr v-for="(a,i) in arr">
      <td>{{i+1}}</td><td>{{a.name}}</td><td>{{a.salary}}</td><td>{{a.job}}</td>
      <td><input type="button" value="删除" @click="del(i)"></td>
    </tr>
    <input type="text" v-model="staff.name" placeholder="姓名">
    <input type="text" v-model="staff.salary" placeholder="工资">
    <input type="text" v-model="staff.job" placeholder="工作">
    <input type="button" value="添加员工" @click="f()">
  </table>
</div>
<script src="https://cdn.staticfile.org/vue/2.2.2/vue.min.js"></script>
<script>
  let v = new Vue({
    el:"body>div",
    data:{
      staff:{name:"",salary:"",job:""},
      arr:[]
    },
    methods:{
      f(){
        //往数组添加对象
        v.arr.push({name:v.staff.name,salary:v.staff.salary,job:v.staff.job})
      },
      del(i){
        //从数组中删除对象,splice(删除的位置，删除的数量)
        v.arr.splice(i,1)
      }
    }
  })

</script>
</body>
</html>